import type { UserAuthInfo } from '@/types/members'
import { getUserAuthInfoAPI } from '@/services/member'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useMemberStore } from './member'

export const useAuthStore = defineStore('userAuth', () => {
  const userAuthInfo = ref<UserAuthInfo[]>([])
  const getUserAuthInfo = async () => {
    const userInfo = useMemberStore().profile
    // 如果用户信息存在，则获取用户认证信息
    if (userInfo) {
      const res = await getUserAuthInfoAPI()
      userAuthInfo.value = res.data
    }
  }
  return {
    userAuthInfo,
    getUserAuthInfo,
  }
})
